package part17;

import java.util.Collections;
import java.util.Iterator;
import java.util.SortedSet;
import java.util.TreeSet;

/**
 * @author wcj
 * @Date 2021/6/1 18:43
 * @Version 1.0
 */
public class Part179 {

    /**
     * sortedSet:按照元素的比较顺序存放元素
     *
     * @param args
     */
    public static void main(String[] args) {
        SortedSet<String> sortedSet = new TreeSet<>();
        Collections.addAll(sortedSet, "one two three four five six seven eight nine".split(" "));
        System.out.println(sortedSet);
        System.out.println(sortedSet.first());
        System.out.println(sortedSet.last());
        Iterator<String> iterator = sortedSet.iterator();
        while (iterator.hasNext()) {
            String next = iterator.next();
            System.out.println(next);
        }
    }
}
